<template>
  <el-card>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">权限管理</a></el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">权限列表</a></el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 表格区域 -->
    <div class="tab-list">
      <el-table :data="rightList" border>
        <el-table-column label="序号" type="index" align="center" width="80px">
        </el-table-column>
        <el-table-column prop="id" label="id" align="center"> </el-table-column>
        <el-table-column prop="authName" label="权限名称" align="center">
        </el-table-column>
        <el-table-column prop="path" label="路径" align="center">
        </el-table-column>

        <el-table-column prop="level" label="层级" align="center">
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.level == 0" size="small"
              >一级</el-tag
            >
            <el-tag type="primary" v-if="scope.row.level == 1" size="small"
              >二级</el-tag
            >
            <el-tag type="success" v-if="scope.row.level == 2" size="small"
              >三级</el-tag
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      rightList: [] //权限列表
    };
  },
  created() {
    this.getRightList();
  },
  methods: {
    async getRightList() {
      let { data: res } = await this.$axios.get("rights/list");
      //   判断是否获取成功
      if (res.meta.status !== 200) return this.$message.error(res.meta.msg);
      console.log(res);
      this.rightList = res.data;
    }
  }
};
</script>

<style lang="less" scoped>
</style>